FROM ubuntu

MAINTAINER lnmp "906280213@qq.com"

# 替换源为国内阿里云的源
# 先备份
RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak
COPY ./sources.list /etc/apt/
RUN apt -y update && apt -y upgrade
RUN apt install -y vim curl wget 
# 添加php8.0的源
RUN apt -y install software-properties-common
RUN add-apt-repository ppa:ondrej/php
RUN apt update
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
RUN apt install -y php8.0 php8.0-dev
RUN apt install -y php8.0-curl php8.0-fpm php8.0-gd php8.0-mysqlnd php8.0-mbstring php8.0-ldap php8.0-bcmath php8.0-soap php8.0-soap php8.0-xml php8.0-zip php8.0-intl php8.0-imagick php8.0-xdebug 

# 安装composer
#RUN wget https://getcomposer.org/composer.phar
#Run composer-stable.phar composer
#RUN chmod +x composer
#RUN mv composer.phar /usr/bin/composer
# 设置composer源为阿里云
#RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

# 安装mysql
#RUN apt-get install -y mysql-server mysql-client

# 添加nginx配置
RUN  add-apt-repository ppa:ondrej/nginx
RUN apt update
RUN apt-get install -y nginx

# 配置nginx
COPY ./default /etc/nginx/sites-available/default

# 编译方式安装redis 6.x
RUN cd ~ && mkdir /var/redistInstall
COPY ./redis-6.0.12.tar.gz /var/redistInstall/
RUN cd /var/redistInstall && tar xvf redis-6.0.12.tar.gz && \
mv redis-6.0.12 redis && cd redis && make && make install
# 配置redis
COPY ./redis.conf /var/redistInstall/
# 安装php redis扩展
RUN pecl install redis
RUN echo "extension=redis.so" >> /etc/php/8.0/cli/conf.d/20-redis.ini
# 添加启动脚本
ADD ./start.sh /start.sh
RUN chmod 755 /start.sh


CMD /start.sh && tail -f

# 暴露端口
#EXPOSE 3306
EXPOSE 80
